Databases are generally used to store data for various applications, including commercial, industrial, technical, scientific and educational applications. Access to the data is usually provided by a “database management system” (DBMS) consisting of an integrated set of computer software, which allows users to uses a structured query language (SQL) statement to interact with databases and provides access to some or all of the data included in the database.
Generally, the DBMS contains an optimizer to perform query optimization on each query. The optimizer considers the possible query execution plans for a query statement and attempts to determine which of those query execution plans will be efficient and cost effective. Generally, an SQL query often generates one or more files (for example, work files) to store temporary result tables while performing the query, and the optimizer usually guesses the size of the generated file and provides one query execution plan based on the statistics information.